import { getNotReadCustomServiceLog, workGoodsSkuModifyList, OrderComplaintPage } from '@/api/workorder'
import { stringToObject } from '@/util/util'
export const tableConfig = {
  hasPage: true,
  // hasCheck: true,
  request: (params) => {
    return getNotReadCustomServiceLog(params)
  },
  dataParse: (res) => {
    const resData = res.data.data
    const data = {
      list: resData.rows,
      total: resData.total
    }
    return data
  },
  columns: [
    {
      prop: 'goodsName',
      label: '蛋糕名称',
    },
    {
      prop: 'goodsSpecs',
      label: '规格',
    },
    {
      prop: 'regionName',
      label: '地区',
    },
    {
      prop: 'warehouseName',
      label: '仓库',
    },
    {
      prop: 'promoter',
      label: '申请人',
    },
    {
      prop: 'xmbzNo',
      label: '后台单号',
    },
    {
      prop: 'remarks',
      label: '备注',
    },
    {
      prop: 'printingState',
      label: '打印状态',
      isSlot: true,
    },
    {
      prop: 'newsTypeName',
      label: '蛋糕状态',
    },
    {
      prop: 'createTime',
      label: '创建时间',
    },
    {
      prop: 'processState',
      label: '工单状态',
      isSlot: true,
    },
    {
      prop: 'operate',
      label: '操作',
      isSlot: true,
    }
  ]
}

export const editTableConfig = {
  hasPage: true,
  unImmediate: true,
  // hasCheck: true,
  request: (params) => {
    return workGoodsSkuModifyList(params)
  },
  dataParse: (res) => {
    const resData = res.data.data
    const data = {
      list: (resData.rows || []).map(item => {
        const fPices = Object.keys(item.beforExtJson);
        const aPrices = Object.keys(item.afterExtJson);

        return {
          ...item,
          beforExtJson: {
            ...item.beforExtJson,
            price: fPices[0],
            list: item.beforExtJson[fPices[0]],
          },
          afterExtJson: {
            ...item.afterExtJson,
            price: aPrices[0],
            list: item.afterExtJson[aPrices[0]],
          },
        }
      }),
      total: resData.total
    }
    return data
  },
  columns: [
    {
      prop: 'xmbzNo',
      label: '后台单号',
    },
    {
      prop: 'extJson',
      label: '改款详情',
      isSlot: true,
      width: '240px',
    },
    {
      prop: 'fall',
      label: '是否补差价',
      isSlot: true,
    },
    {
      prop: 'reason',
      label: '差价单号/原因',
    },
    {
      prop: 'handleState',
      label: '状态',
      isSlot: true,
    },
    {
      prop: 'processingResults',
      label: '处理结果',
    },
    {
      prop: 'source',
      label: '工单来源',
      isSlot: true,
    },
    {
      prop: 'operator',
      label: '申请人',
    },
    {
      prop: 'roleNames',
      label: '申请人角色',
    },
    {
      prop: 'personDispose',
      label: '处理人',
    },
    {
      prop: 'createTime',
      label: '创建时间',
    },
    {
      prop: 'endTime',
      label: '审批时间',
    },
    {
      prop: 'operate',
      label: '操作',
      isSlot: true,
    }
  ]
}

export const complaintTableConfig = {
  hasPage: true,
  unImmediate: true,
  // hasCheck: true,
  request: (params) => {
    return OrderComplaintPage(params)
  },
  dataParse: (res) => {
    const resData = res.data.data
    const data = {
      list: resData.rows || [],
      total: resData.total
    }
    return data
  },
  columns: [
    {
      prop: 'complaintLevelName',
      label: '等级',
      isSlot: true,
      fixed: 'left',
    },
    {
      prop: 'xmbzNo',
      label: '后台单号',
    },
    {
      prop: 'cityName',
      label: '城市',
    },
    {
      prop: 'deliveryTime',
      label: '配送时间',
      isSlot: true,
      width: '180px',
    },
    {
      prop: 'createTime',
      label: '创建时间',
    },
    {
      prop: 'receiverPhone',
      label: '收货人电话',
    },
    {
      prop: 'phone',
      label: '联系电话',
    },
    {
      prop: 'handleStateName',
      label: '处理状态',
    },
    {
      prop: 'complaintContent',
      label: '投诉内容',
      isSlot: true,
    },
    {
      prop: 'complaintChannelName',
      label: '投诉渠道',
    },
    {
      prop: 'responsibleDepartmentErrorText',
      label: '部门失误类型',
    },
    {
      prop: 'operator',
      label: '申请人',
    },
    {
      prop: 'personLiable',
      label: '责任人',
    },
    {
      prop: 'personUpdate',
      label: '跟进人',
    },
    {
      prop: 'personDispose',
      label: '处理人',
    },
    {
      prop: 'count',
      label: '投诉次序',
      fixed: 'right',
    },
    {
      prop: 'operate',
      label: '操作',
      isSlot: true,
      fixed: 'right',
    }
  ]
}